package com.tarena.lbs.message.web.controller;

import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.base.protocol.pager.BasePageList;
import com.tarena.lbs.message.web.service.TimingMsgTaskService;
import com.tarena.lbs.pojo.message.dos.TaskInfo;
import com.tarena.lbs.pojo.message.param.TimingMsgTaskInsertParam;
import com.tarena.lbs.pojo.message.param.TimingMsgTaskQueryParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 定时消息任务管理控制器
 */
@RestController
@RequestMapping("/admin/message/timingMsgTask")
@Api(tags = "定时消息任务管理")
@CrossOrigin
public class TimingMsgTaskController {
    @Autowired
    TimingMsgTaskService timingMsgTaskService;

    /**
     * 新增定时消息任务
     *
     * @param timingMsgTaskInsertParam 定时消息任务插入参数
     * @return Result<Boolean>对象
     */
    @ApiOperation("新增定时消息任务")
    @PostMapping("/insert")
    public Result<Boolean> insert(@RequestBody TimingMsgTaskInsertParam timingMsgTaskInsertParam) {
        boolean result = timingMsgTaskService.insert(timingMsgTaskInsertParam);
        return new Result<>(result);
    }

    @ApiOperation("定时消息任务列表")
    @PostMapping("/getTaskList")
    public Result<BasePageList<TaskInfo>> getTaskList(@RequestBody TimingMsgTaskQueryParam param) {
        return new Result<>(timingMsgTaskService.getTaskList(param));
    }
}
